const Router = require('koa-router');
const { BeSuccess } = require('../utils');
const { handleProject } = require('../git/deploy');

const router = new Router({ prefix: '/v1/deploy' });

router.get('/list', async (ctx, next) => {
  // const res = await handleGetAllUser();
  ctx.body = BeSuccess({ name: 'zs', age: 10 });
});

router.post('/submit', async(ctx, next) => {
  const body = ctx.request.body;
  const { projectName, branchName } = body;
  // /Users/juran/Desktop/workspace/front_end/server_koa
  // console.log(process.cwd());
  handleProject('web-thousand-home-phone', 'master', 'https://gitee.com/zmyxixihaha/web-thousand-home-phone.git');
  ctx.body = BeSuccess(true);
});

module.exports = router;